﻿<%@ Page Language="C#" MasterPageFile="~/MasterPageSERIX.Master" AutoEventWireup="true"
    CodeBehind="ValoresOrganizacoesManut.aspx.cs" Inherits="SERIX.ValoresOrganizacoesManut"
    Title="RME por Organização" %>

<%@ Register Src="Controles/lovGenerica.ascx" TagName="lovGenerica" TagPrefix="uc1" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <table width="97%" border="0" cellspacing="0" cellpadding="2" align="center">
        <tr>
            <td class="secao_titulo" style="width: 284px">
                Registro Mensal/Organização<hr class="linhaHorizontal" style="width: 740px" />
            </td>
        </tr>
        <tr>
            <td align="left" class="erro">
                <asp:Label ID="lblErro" runat="server" CssClass="erro" Text="*Erro: " Visible="False"
                    Width="740px" TabIndex="-1" OnLoad="lblErro_Load"></asp:Label>
            </td>
        </tr>
    </table>
    <table align="center" border="0" cellpadding="2" cellspacing="0" width="97%">
        <tr>
            <td align="center" class="grid_titulo">
                <span style="color: #FFFFFF">Ano: </span>
                <asp:TextBox ID="txtAno" Columns="4" MaxLength="4" runat="server" OnPreRender="txtAno_PreRender"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtAno"
                    CssClass="erro_pesquisa" ErrorMessage="*Campo obrigatório!" Display="Dynamic"
                    TabIndex="-1" Width="174px"></asp:RequiredFieldValidator>
                &nbsp;&nbsp;&nbsp;<span style="color: #FFFFFF">&nbsp;Mês: </span>
                <asp:DropDownList ID="ddlMeses" runat="server" OnPreRender="ddlMeses_PreRender">
                    <asp:ListItem />
                    <asp:ListItem Value="1" Text="Janeiro"></asp:ListItem>
                    <asp:ListItem Value="2" Text="Fevereiro"></asp:ListItem>
                    <asp:ListItem Value="3" Text="Março"></asp:ListItem>
                    <asp:ListItem Value="4" Text="Abril"></asp:ListItem>
                    <asp:ListItem Value="5" Text="Maio"></asp:ListItem>
                    <asp:ListItem Value="6" Text="Junho"></asp:ListItem>
                    <asp:ListItem Value="7" Text="Julho"></asp:ListItem>
                    <asp:ListItem Value="8" Text="Agosto"></asp:ListItem>
                    <asp:ListItem Value="9" Text="Setembro"></asp:ListItem>
                    <asp:ListItem Value="10" Text="Outubro"></asp:ListItem>
                    <asp:ListItem Value="11" Text="Novembro"></asp:ListItem>
                    <asp:ListItem Value="12" Text="Dezembro"></asp:ListItem>
                </asp:DropDownList>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="ddlMeses"
                    CssClass="erro_pesquisa" ErrorMessage="*Campo obrigatório!" Display="Dynamic"
                    TabIndex="-1" Width="174px"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td align="center" class="grid_titulo" colspan="2">
                <span style="color: #FFFFFF">Organização: </span>
                <asp:TextBox ID="txtOrganizacao" runat="server" Columns="40" MaxLength="60" Enabled="false"></asp:TextBox>
                <uc1:lovGenerica ID="lovOrganizacoes" runat="server" />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="txtOrganizacao"
                    CssClass="erro_pesquisa" ErrorMessage="*Campo obrigatório!" Display="Dynamic"
                    TabIndex="-1" Width="174px"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td align="center" class="grid_titulo" colspan="2">
                <span style="color: #FFFFFF">Programa: </span>
                <asp:DropDownList ID="ddlProgramas" runat="server" DataSourceID="SqlProgramas" DataTextField="NOM_PROG"
                    DataValueField="IDT_PROG" OnSelectedIndexChanged="ddlProgramas_SelectedIndexChanged"
                    AutoPostBack="True">
                </asp:DropDownList>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="ddlProgramas"
                    CssClass="erro_pesquisa" ErrorMessage="*Campo obrigatório!" Display="Dynamic"
                    TabIndex="-1" Width="174px"></asp:RequiredFieldValidator>
                <asp:SqlDataSource ID="SqlProgramas" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                    ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
                    SelectCommand="select p.idt_prog, p.nom_prog 
                                       from serix.srx_programas p join serix.srx_programas_municipios pm on (p.idt_prog = pm.idt_prog)
                                       where pm.idt_mun = ( select idt_mun
                                                               from srx_organizacoes
                                                               where idt_org = :P_IDT_ORG )                         
                                       order by nom_prog">
                    <SelectParameters>
                        <asp:Parameter Name="P_IDT_ORG" />
                    </SelectParameters>
                </asp:SqlDataSource>
            </td>
        </tr>
        <tr>
            <td align="center" class="grid_titulo" colspan="2">
                <span style="color: #FFFFFF">Ação: </span>
                <asp:DropDownList ID="ddlAcoes" runat="server" DataSourceID="SqlAcoesPrograma" DataTextField="DSC_ACAO"
                    DataValueField="IDT_ACAO" AutoPostBack="True" OnSelectedIndexChanged="ddlAcoes_SelectedIndexChanged">
                </asp:DropDownList>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ControlToValidate="ddlAcoes"
                    CssClass="erro_pesquisa" ErrorMessage="*Campo obrigatório!" Display="Dynamic"
                    TabIndex="-1" Width="174px"></asp:RequiredFieldValidator>
                <asp:SqlDataSource ID="SqlAcoesPrograma" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                    ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
                    SelectCommand="SELECT A.IDT_ACAO, A.DSC_ACAO 
                                       FROM SERIX.SRX_ACOES_PROGRAMAS A 
                                       WHERE A.IDT_PROG = :PARAM AND
                                             exists( select 1
                                                       FROM SERIX.SRX_INDICADORES_ACOES I
                                                       where A.IDT_PROG = I.IDT_PROG AND
                                                             A.IDT_ACAO = I.IDT_ACAO AND I.TPO_VINC = 'O' )
                                       ORDER BY A.DSC_ACAO">
                    <SelectParameters>
                        <asp:Parameter Name="PARAM" />
                    </SelectParameters>
                </asp:SqlDataSource>
            </td>
        </tr>
        <tr>
            <td align="center" class="grid_titulo" colspan="2">
                <span style="color: #FFFFFF">Indicador: </span>
                <asp:DropDownList ID="ddlIndicadores" runat="server" DataSourceID="SqlIndicadoresAcao"
                    DataTextField="DSC_IND" DataValueField="IDT_IND">
                </asp:DropDownList>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="ddlIndicadores"
                    CssClass="erro_pesquisa" ErrorMessage="*Campo obrigatório!" Display="Dynamic"
                    TabIndex="-1" Width="174px"></asp:RequiredFieldValidator>
                <asp:SqlDataSource ID="SqlIndicadoresAcao" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                    ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
                    SelectCommand="SELECT IDT_IND, DSC_IND, TPO_VINC 
                                       FROM Serix.SRX_INDICADORES_ACOES 
                                       WHERE IDT_ACAO = :PARAM AND TPO_VINC = 'O' 
                                       ORDER BY DSC_IND">
                    <SelectParameters>
                        <asp:Parameter Name="PARAM" />
                    </SelectParameters>
                </asp:SqlDataSource>
            </td>
        </tr>
        <tr>
            <td align="center" class="grid_titulo">
                <span style="color: #FFFFFF">Técnico: </span>
                <asp:TextBox ID="txtNomeTecnico" runat="server" Columns="40" MaxLength="60" Enabled="false"></asp:TextBox>
                <uc1:lovGenerica ID="lovTecnicos" runat="server" />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="txtNomeTecnico"
                    CssClass="erro_pesquisa" ErrorMessage="*Campo obrigatório!" Display="Dynamic"
                    TabIndex="-1" Width="174px"></asp:RequiredFieldValidator>                
                &nbsp;&nbsp;&nbsp;<asp:Button ID="btnPequisar" runat="server" Font-Bold="True" OnClick="btnPequisar_Click"
                    TabIndex="5" Text="Pesquisar" Width="80px" />
                &#160;&#160;<asp:Button ID="btnLimpar" runat="server" CausesValidation="false" Font-Bold="True"
                    OnClick="btnLimpar_Click" TabIndex="6" Text="Limpar" UseSubmitBehavior="False"
                    Width="80px" />
            </td>
        </tr>        
        <tr>
            <td align="left" style="color: #000000">
                <asp:Label ID="lblFiltro" runat="server" CssClass="filtro" TabIndex="-1" Text="Filtro: "></asp:Label>
            </td>
        </tr>
        <tr>
            <td align="center" style="color: #000000">
                <asp:GridView ID="gridView" runat="server" AutoGenerateColumns="False" CssClass="grid"
                    EmptyDataText="Nenhum registro encontrado." OnRowDataBound="gridView_RowDataBound">
                    <AlternatingRowStyle CssClass="row_alter" />
                    <Columns>
                        <asp:TemplateField Visible="False">
                            <ItemTemplate>
                                <asp:Label ID="lblIdtOrg" runat="server" Text='<%# Bind("IDT_ORG") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField Visible="False">
                            <ItemTemplate>
                                <asp:Label ID="lblIdtInd" runat="server" Text='<%# Bind("IDT_IND") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField Visible="False">
                            <ItemTemplate>
                                <asp:Label ID="lblIdtTpoMed" runat="server" Text='<%# Bind("IDT_TPO_MED") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField Visible="False">
                            <ItemTemplate>
                                <asp:Label ID="lblIdtLotacao" runat="server" Text='<%# Bind("IDT_LOTACAO") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField Visible="False">
                            <ItemTemplate>
                                <asp:Label ID="lblIdtDesc" runat="server" Text='<%# Bind("IDT_DESC") %>'></asp:Label>
                            </ItemTemplate>
                       </asp:TemplateField>
                       <asp:BoundField DataField="TIT_DESCRICAO" HeaderText="Tipo" ItemStyle-Width="250px">
                            <ItemStyle Width="220px"></ItemStyle>
                        </asp:BoundField>
                        <asp:BoundField DataField="DESCRICAO" HeaderText="Descrição" ItemStyle-Width="520px">
                            <ItemStyle Width="520px"></ItemStyle>
                        </asp:BoundField>
                        <asp:BoundField DataField="NOM_ORG" HeaderText="Organização">
                            <ItemStyle Width="620px"></ItemStyle>
                        </asp:BoundField>
                        <asp:BoundField DataField="UNIDADE" HeaderText="Unidade">
                            <ItemStyle Width="70px" HorizontalAlign="Center"></ItemStyle>
                        </asp:BoundField>
                        <asp:BoundField DataField="PRODUCAO" HeaderText="Produção" >
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:BoundField DataField="META" HeaderText="Meta">
                            <ItemStyle Width="200px" HorizontalAlign="Center"></ItemStyle>
                        </asp:BoundField>
                        <asp:TemplateField HeaderText="Valor">
                            <ItemTemplate>
                                <asp:TextBox ID="txtValorRateio" runat="server" Columns="10" MaxLength="12" Text="<%# Bind('VALOR_RATEIO') %>"></asp:TextBox>
                            </ItemTemplate>
                            <ItemStyle HorizontalAlign="Center" Width="150px" />
                        </asp:TemplateField>
                        <asp:TemplateField FooterText="Excluir" HeaderText="Excluir" ItemStyle-Width="70px">
                            <ItemTemplate>
                                <asp:ImageButton ID="imbExcluirValor" runat="server" CausesValidation="False" ImageUrl="Imagens/botoes/Delete.png"
                                    OnClick="imbExcluirValor_Click" />
                                <cc1:ConfirmButtonExtender ID="imbExcluirValor_ConfirmButtonExtender" runat="server"
                                    ConfirmText="Confirma a exclusão deste lançamento?" Enabled="True" TargetControlID="imbExcluirValor">
                                </cc1:ConfirmButtonExtender>
                            </ItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" />
                            <ItemStyle HorizontalAlign="Center" Width="70px"/>
                        </asp:TemplateField>
                    </Columns>
                    <EmptyDataRowStyle CssClass="emptyrow" />
                    <FooterStyle CssClass="footer" />
                    <HeaderStyle CssClass="header" />
                    <PagerStyle CssClass="pager" />
                    <RowStyle CssClass="row" />
                </asp:GridView>
            </td>
        </tr>
        <tr>
            <td style="height: 30px; color: black;" width="100%" align="center">
                <asp:Button ID="Ok_Button" runat="server" Font-Bold="True" Text="Ok" Width="80px"
                    OnClick="Ok_Button_Click" />
                &nbsp;<asp:Button ID="Cancelar_Button" runat="server" Font-Bold="True" OnClick="Cancelar_Button_Click"
                    Text="Cancelar" Width="80px" CausesValidation="False" />
            </td>
        </tr>
    </table>
</asp:Content>
